home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / vltj5867.lha / VLT / rexx / MarginBell.vlt < prev    next >
Text File  |  1994-03-27  |  1KB  |  59 lines

  1. /** MarginBell.vlt
  2. *
  3. *   Example program to intercept keystrokes.
  4. *   This one implements a margin bell at 72 colums
  5. *
  6. **/
  7. margincol = 72
  8. /*
  9. *   Add libraries if necessary
  10. */
  11. if show("l", "rexxarplib.library") = 0 then do
  12.    check = addlib('rexxsupport.library', 0, -30, 0)
  13.    check = addlib('rexxarplib.library',  0, -30, 0)
  14. end
  15. /*
  16. *   Open a port
  17. */
  18. mp = openport(MARGIN_BELL)
  19. /*
  20. *   Tell VLT to send us stuff
  21. */
  22. "wedge keystrokes MARGIN_BELL"
  23. /*
  24. *   Loop until quitflag is 1, waiting for packets
  25. */
  26. do forever
  27.    if quitflag = 1 then leave
  28.    t = waitpkt(MARGIN_BELL)
  29. /*
  30. *   We got a number of packets. Loop over all of them.
  31. */
  32.    do ff = 1
  33.       p = getpkt(MARGIN_BELL)
  34.       if c2d(p) = 0 then leave ff
  35.       line = getarg(p)
  36.       t = reply(p, 1)
  37. /*
  38. *   Got something. Find out what...
  39. */
  40.       parse var line command code qual iaddr char .
  41. /*
  42. *   If we got an "esc", quit.
  43. */
  44.       if char = '1B'x then do
  45.          quitflag = 1
  46.          "$1: BEEP; delay .7; BEEP; delay .7; BEEP"
  47.       end
  48. /*
  49. *   Else check the current cursor x position. Send VLT a BEEP command if it
  50. *   is at the margin column.
  51. */
  52.       else do
  53.          "extract x"
  54.          if VLT.x > margincol then "BEEP"
  55.       end
  56.    end
  57. end
  58.  
  59.